package cn.cqie.attendance.common.util;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

@Data
@NoArgsConstructor
public class Page<T> implements Serializable {


    private static final long serialVersionUID = 1L;
    public static final Page SUCCESS = new Page(200, "success");
    public static final Page EXCEPTION = new Page(500,"exception");
    public static final Page INFOERROR = new Page(201,"info error");
    public static final Page UNAUTHOR = new Page(401,"unauthor");
    public static final Page FAIL = new Page(999,"fail");
    /**
     * 200                    // 成功
     * 500                    // 后台发生异常
     * 201                    // 用户信息错误
     * 401                    // 未授权
     * 999                    // 失败
     */
    private int code;
    /**
     * 成功使用 'success'
     * 失败用  'fail'
     */
    private String msg;
    /**
     * 当前页
     */
    private long current;
    /**
     * 每页的数据条数
     */
    private long size;
    /**
     * 数据总条数
     */
    private long total;
    /**
     * 传输数据
     */
    private List<T> data;

    private T res;

    public Page(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Page(int code, String msg, long current, long size, long total, List<T> data) {
        this.code = code;
        this.msg = msg;
        this.current = current;
        this.size = size;
        this.total = total;
        this.data = data;
    }

    public Page(int code, String msg, List<T> data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public Page(int code, String msg, T res) {
        this.code = code;
        this.msg = msg;
        this.res = res;
    }
}
